package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.HotelDetail;
import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.StrategyContent;
import cn.wolfcode.trip.base.domain.Hotel;
import cn.wolfcode.trip.base.mapper.HotelDetailMapper;
import cn.wolfcode.trip.base.mapper.StrategyContentMapper;
import cn.wolfcode.trip.base.mapper.HotelMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IHotelService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class HotelServiceImpl implements IHotelService {
    @Autowired
    private HotelMapper hotelMapper;
    @Autowired
    private HotelDetailMapper detailMapper;


    public PageInfo<Hotel> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Hotel> list = hotelMapper.selectForList(qo);
        return new PageInfo<>(list);
    }

    public void saveOrUpdate(Hotel entity) {
        if (entity.getId() == null) {
            hotelMapper.insert(entity);
        } else {
            hotelMapper.updateByPrimaryKey(entity);
        }
    }

    @Override
    public List<Hotel> list() {
        return hotelMapper.selectAll();
    }

    /**
     * 根据酒店id获取房型liebiao
     * @param hotelId
     * @return
     */
    public List<HotelDetail> queryHotelDetailByHotelId(Long hotelId) {

        return detailMapper.selectHotelDetialByHotelId(hotelId);
    }

    /**
     * 根据id获取酒店
     * @param hotelId
     * @return
     */
    public Hotel queryHotelById(Long hotelId) {
        return hotelMapper.selectByPrimaryKey(hotelId);
    }

}
